package org.niugang.security.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 跨域配置
 *
 * @author Created by niugang on 2019/5/24/13:45
 */
@Configuration
public class CorsConfig {

    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                //addMapping 跨域所能访问的路径
                //allowedOrigins：那些域可以访问，默认为任何域都可以访问
                registry.addMapping("/**").allowedOrigins("*");
            }
        };
    }

}
